package fudan.chenkai.linkup;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
import fudan.chenkai.linkup.view.GameView;

public class MyDialog extends Dialog{

	/**
	 * @uml.property  name="gameview"
	 * @uml.associationEnd  multiplicity="(1 1)"
	 */
	private GameView gameview;
	/**
	 * @uml.property  name="context"
	 * @uml.associationEnd  multiplicity="(1 1)"
	 */
	private Context context;
	
	public MyDialog(Context context, GameView gameview, String msg, int score) {
		super(context,R.style.dialog);
		this.gameview = gameview;
		this.context = context;
		this.setContentView(R.layout.dialog);
		TextView text_msg = (TextView) findViewById(R.id.text_message);
		TextView text_score = (TextView) findViewById(R.id.text_score);
		ImageButton btn_menu = (ImageButton) findViewById(R.id.menu_imgbtn);
		ImageButton btn_next = (ImageButton) findViewById(R.id.next_imgbtn);
		ImageButton btn_replay = (ImageButton) findViewById(R.id.replay_imgbtn);
		
		text_msg.setText(msg);
		text_score.setText(text_score.getText().toString().replace("$", String.valueOf(score)));
		btn_menu.setOnClickListener(menu_button_listener);
		btn_next.setOnClickListener(next_button_listener);
		btn_replay.setOnClickListener(replay_button_listener);
		this.setCancelable(false);
	}
	
    /**
	 * @uml.property  name="menu_button_listener"
	 * @uml.associationEnd  multiplicity="(1 1)"
	 */
    private ImageButton.OnClickListener menu_button_listener = new ImageButton.OnClickListener(){
    	public void onClick(View v){
    		MyDialog.this.dismiss();
    	}
    };
    
    /**
	 * @uml.property  name="next_button_listener"
	 * @uml.associationEnd  multiplicity="(1 1)"
	 */
    private ImageButton.OnClickListener next_button_listener = new ImageButton.OnClickListener(){
    	public void onClick(View v){
    		MyDialog.this.dismiss();
			gameview.startNextPlay();
    	}
    };    
    
    /**
	 * @uml.property  name="replay_button_listener"
	 * @uml.associationEnd  multiplicity="(1 1)"
	 */
    private ImageButton.OnClickListener replay_button_listener = new ImageButton.OnClickListener(){
    	public void onClick(View v){
    		MyDialog.this.dismiss();
			gameview.replay();
    	}
    };
}
